package cn.kinoko.service.common.event.component;

import cn.kinoko.service.common.event.EventTopicEnum;

import java.util.Collection;

/**
 * 事件接收者（生产者）
 *
 * @author kinoko
 */
public class EventReceiver {

    /**
     * 事件接收
     *
     * @param eventType   事件类型
     * @param uid      用户id
     * @param eventParams 事件参数
     */
    public static void receive(EventTopicEnum eventType, Long uid, Object eventParams) {
        Event event = new Event();
        event.setTimestamp(System.currentTimeMillis());
        event.setEventTopic(eventType);
        event.setUserId(uid);
        event.setEventParams(eventParams);
        receive(event);
    }

    /**
     * 事件接收
     *
     * @param event 事件
     */
    public static synchronized <T> void receive(Event event) {
        EventDistributeHandler.EVENT_TRACKING_QUEUE.add(event);
    }

    /**
     * 事件接收
     *
     * @param event 事件
     */
    public static synchronized void receive(Collection<Event> event) {
        EventDistributeHandler.EVENT_TRACKING_QUEUE.addAll(event);
    }

}	
